import React, {Component} from 'react';
import {Platform, StyleSheet, Text, TextInput, View, Image, AsyncStorage, Keyboard} from 'react-native';
import splashImage from '../assets/images/splash.png';
import {ActivityIndicator} from 'antd-mobile-rn';
import appUtils from "../utils/appUtils";
import { Actions } from 'react-native-router-flux';

export default class Splash extends Component {

    componentDidMount() {
        setTimeout(()=>{
            appUtils.checkLogin().then(()=>{
                Actions.reset("home")
            }).catch(()=>{
                Actions.reset("login")
            })
        },1500)

    }

    render() {
        return (
            <View style={styles.container}>
                <Image source={splashImage} style={styles.splash}>

                </Image>
                <View style={styles.loading}>
                    <ActivityIndicator color="white"/>
                </View>
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container: {
        width: "100%",
        height: "100%",
        backgroundColor: '#f0f0f0',
        position: 'relative'
    },
    splash: {
        width: "100%",
        height: "100%",
        position: "absolute",
        left: 0,
        top: 0,
    },
    loading: {
        bottom: 40,
        zIndex: 2,
        width: "100%",
        position: "absolute",
        // backgroundColor: "red",
    }
});